/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Frank
 */

import lpsolve.*;
public class Modelo {
    public static void main(String[] args) throws LpSolveException {
        //Crear un problema con 11 variables
        LpSolve solver = LpSolve.makeLp(0, 11);                
        
        //Restricciones
        solver.strAddConstraint("0 1 -1 0 0 0 0 0 0 0 0", LpSolve.GE, 200);
        solver.strAddConstraint("0 1 0 -1 0 0 0 0 0 0 0", LpSolve.GE, 250);
        solver.strAddConstraint("0 1 0 0 -1 0 0 0 0 0 0", LpSolve.GE, 150);
        solver.strAddConstraint("1 0 -1 0 0 0 0 0 0 0 0", LpSolve.GE, -10);
        solver.strAddConstraint("1 0 0 -1 0 0 0 0 0 0 0", LpSolve.GE, 0);
        solver.strAddConstraint("1 0 0 0 -1 0 0 0 0 0 0", LpSolve.GE, -450);
        solver.strAddConstraint("0 0 1 -1 0 1000 0 0 0 0 0", LpSolve.GE, 260);
        solver.strAddConstraint("0 0 -1 1 0 -1000 0 0 0 0 0", LpSolve.GE, -788);
        solver.strAddConstraint("0 0 1 0 -1 0 1000 0 0 0 0", LpSolve.GE, 157);
        solver.strAddConstraint("0 0 -1 0 1 0 -1000 0 0 0 0", LpSolve.GE, -780);
        solver.strAddConstraint("0 0 -1 1 0 0 0 1000 0 0 0", LpSolve.GE, 212);
        solver.strAddConstraint("0 0 1 -1 0 0 0 -1000 0 0 0", LpSolve.GE, -740);
        solver.strAddConstraint("0 0 0 1 -1 0 0 0 1000 0 0", LpSolve.GE, 151);
        solver.strAddConstraint("0 0 0 -1 1 0 0 0 -1000 0 0", LpSolve.GE, -742);
        solver.strAddConstraint("0 0 -1 0 1 0 0 0 0 1000 0", LpSolve.GE, 220);
        solver.strAddConstraint("0 0 1 0 -1 0 0 0 0 -1000 0", LpSolve.GE, -843);
        solver.strAddConstraint("0 0 0 -1 1 0 0 0 0 0 1000", LpSolve.GE, 258);
        solver.strAddConstraint("0 0 0 1 -1 0 0 0 0 0 -1000", LpSolve.GE, -849);
        
        //Función objetivo
        solver.strSetObjFn("1 0 0 0 0 0 0 0 0 0 0");
       
        solver.setBinary(6, true);
        solver.setBinary(7, true);
        solver.setBinary(8, true);
        solver.setBinary(9, true);
        solver.setBinary(10, true);
        solver.setBinary(11, true);
       
        solver.setMinim();
        solver.solve();
        
        //Imprimir solución
        System.out.println("Valor de la función objetivo: " + solver.getObjective());
        double[] var = solver.getPtrVariables(); 
        System.out.println("Valor de te: " + var[1]);
        System.out.println("Valor de y1: " + var[2]);
        System.out.println("Valor de y2: " + var[3]);
        System.out.println("Valor de y3: " + var[4]);
        System.out.println("Valor de x12: " + var[5]);
        System.out.println("Valor de x13: " + var[6]);
        System.out.println("Valor de x21: " + var[7]);
        System.out.println("Valor de x23: " + var[8]);
        System.out.println("Valor de x31: " + var[9]);
        System.out.println("Valor de x32: " + var[10]);
        
        //Borrar el problema y liberar memoria
        solver.deleteLp();
    }
}